<template>
  <div class="border">
    <div class="lan"></div>
    <div class="p">
      <p><span class="p">新增服务</span></p>
    </div>
    <el-form ref="form" :model="form" label-width="100px">
      <span>居民信息</span>
      <br />

      <el-row :gutter="20">
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="选择居民*">
              <el-select
                v-model="id"
                placeholder="请选择"
                @change="record_idrecord_id"
              >
                <el-option
                  v-for="item4 in options10"
                  :key="item4.value"
                  :label="item4.record_name + ' ' + item4.sex + '' + item4.age"
                  :value="item4.record_id"
                >
                </el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="身份证号*">
              <el-input v-model="form2.record_card"></el-input>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="性别*">
              <el-select v-model="form2.sex" placeholder="请选择">
                <el-option label="男" value="男"></el-option>
                <el-option label="女" value="女 "></el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="出生年月*">
              <el-col :span="11">
                <el-date-picker
                  type="date"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                  v-model="form2.commencement_date"
                  style="width: 200%"
                ></el-date-picker>
              </el-col>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="联系电话*">
              <el-input v-model="form2.record_phone"></el-input>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="现居地*">
              <el-input v-model="form2.present_address"></el-input>
            </el-form-item></div
        ></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="家庭成员 " style="margin-left: 50px">
              <!-- Form -->
              <el-button type="text" @click="dialogFormVisible = true"
                >+关联成员</el-button
              >
            </el-form-item>
          </div></el-col
        >
      </el-row>

      <hr />
      <span>服务信息</span>
      <br />
      <el-row :gutter="20">
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务编号*">
              <el-input v-model="form.record_id" disabled></el-input>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务机构*">
              <el-select
                v-model="form.record_organization"
                placeholder="请选择"
              >
                <el-option
                  v-for="item4 in options2"
                  :key="item4.value"
                  :label="item4.label"
                  :value="item4.value"
                >
                </el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务团队*">
              <el-select v-model="form.record_doctor_team" placeholder="请选择">
                <el-option
                  v-for="item4 in options3"
                  :key="item4.value"
                  :label="item4.label"
                  :value="item4.value"
                >
                </el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务医生*">
              <el-select v-model="form.record_doctor" placeholder="请选择">
                <el-option
                  v-for="item4 in options9"
                  :key="item4.value"
                  :label="item4.label"
                  :value="item4.value"
                >
                </el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务包*">
              <el-select v-model="form.record_server" placeholder="请选择">
                <el-option
                  v-for="item4 in options4"
                  :key="item4.value"
                  :label="item4.label"
                  :value="item4.value"
                >
                </el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务项目*">
              <el-select v-model="form.contract_type" placeholder="请选择">
                <el-option
                  v-for="item4 in options5"
                  :key="item4.value"
                  :label="item4.label"
                  :value="item4.value"
                >
                </el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务地点*">
              <el-select v-model="form.pid" placeholder="请选择">
                <el-option label="签约人家里" value="签约人家里"></el-option>
                <el-option label="机构门诊" value="机构门诊"></el-option>
              </el-select>
            </el-form-item></div
        ></el-col>
        <el-col :span="8"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务时间*">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                v-model="form.timeof_payment"
                style="width: 72%"
              ></el-date-picker>
            </el-form-item></div
        ></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="16"
          ><div class="grid-content bg-purple">
            <el-form-item label="服务备注*">
              <el-input
                type="textarea"
                :rows="5"
                placeholder="请输入内容"
                v-model="form.signeda_note"
                style="width: 580px"
              >
              </el-input>
            </el-form-item></div
        ></el-col>
      </el-row>
      <hr />
      <br />
      <br />
      <br />

      <el-button type="primary" class="addBtn" @click="subBtn"
        >提交审核</el-button
      >
      <el-button type="primary" class="bbb" @click="goOff">返回</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      options10: [],
      options9: [
        {
          value: "李明明",
          label: "李明明",
        },
        {
          value: "王汉文",
          label: "王汉文",
        },
        {
          value: "李敏金",
          label: "李敏金",
        },
      ],
      options1: [
        {
          value: "1",
          label: "已完成",
        },
        {
          value: "2",
          label: "已取消",
        },
      ],
      options2: [
        {
          value: "1",
          label: "罗西社区服务中心",
        },
        {
          value: "2",
          label: "天明社区服务中心",
        },
        {
          value: "3",
          label: "民进中心服务中心",
        },
      ],
      options3: [
        {
          value: "1",
          label: "李明明",
        },
        {
          value: "2",
          label: "王浩团队",
        },
        {
          value: "3",
          label: "胡曼团队",
        },
        {
          value: "4",
          label: "李维团队",
        },
      ],
      options4: [
        {
          value: "1",
          label: "基础包 ￥240",
        },
        {
          value: "2",
          label: "0-6岁儿童服务包 ￥340",
        },
        {
          value: "3",
          label: "老年人服务包 ￥340",
        },
        {
          value: "4",
          label: "慢性病服务包 ￥340",
        },
      ],
      options5: [
        {
          value: "1",
          label: "随访服务",
        },
        {
          value: "2",
          label: "血糖监测",
        },
        {
          value: "3",
          label: "血压监测",
        },
      ],
      id: "",
      form2: {
        record_name: "",
        sex: "",
        record_card: "",
        commencement_date: "",
        present_address: "",
        record_phone: "",
        age: "",
      },
      form: {
        record_organization: "",
        record_doctor_team: "",
        record_doctor: "",
        contract_type: "",
        record_server: "",
        // personEle:'',
        pid: "",
        timeof_payment: "",
        signeda_note: "",
        record_id: "",
      },
      options: [
        { name: "慢病护理", label: "one" },
        { name: "高血压", label: "tow" },
        { name: "高血糖", label: "three" },
        { name: "高血脂", label: "four" },
      ],
    };
  },
  created() {
    this.getResident(),
      // 调用获取当前日期的方法加四位随机数  赋值表单中的项目编号

      (this.form.record_id =
        this.getProjectNum() + Math.floor(Math.random() * 10000)); // 如果是6位或者8位随机数，相应的 *1000000或者 *100000000就行了
  },
  methods: {
    findRecordById() {
      this.$axios({
        url: "/api/record/findRecordById",
        method: "POST",
        params: {
          record_id: this.id,
        },
      }).then((res) => {
        this.form2 = res.data;
        this.form.record_id = res.data.data.record_id;
        console.log(res.data.id);
      });
    },

    getResident() {
      this.$axios({
        url: "api/record/findRecord",
        mounted: "GET",
      }).then((res) => {
        console.log(res);
        this.options10 = res.data.data;
      });
    },
    subBtn() {
      this.$axios({
        url: "api/record/findRecordModify",
        mounted: "post",
        traditional: true,
        params: { ...this.form },
      });
    },
    goOff() {
      this.$router.replace("/pending");
    },
    getProjectNum() {
      const projectTime = new Date(); // 当前中国标准时间
      const Year = projectTime.getFullYear(); // 获取当前年份 支持IE和火狐浏览器.
      const Month = (projectTime.getMonth() + 1).toString(); // 获取中国区月份
      const Day = projectTime.getDate(); // 获取几号
      console.log(Day);
      var CurrentDate = Year;
      if (Month >= 10) {
        // 判断月份和几号是否大于10或者小于10
        CurrentDate += Month;
      } else {
        CurrentDate += "0" + Month;
      }
      if (Day >= 10) {
        CurrentDate += Day;
      } else {
        CurrentDate += "0" + Day;
      }
      return Number(CurrentDate);
    },
  },
};
</script>

<style  scoped>
html,
body {
  height: 100%;
  background-color: #f2f7fb;
}

html {
  display: block;
}

.border {
  border-width: 0px;
  left: 0px;
  top: 0px;
  width: 90%;
  height: 912px;
  background: inherit;
  background-color: rgb(255, 255, 255);
  border: none;
  border-radius: 0px;
  -moz-box-shadow: none;
  -webkit-box-shadow: none;
  box-shadow: none;
  margin-left: 4%;
  margin-top: 1%;
  padding: 15px;

}
.lan {
  border-width: 0px;
  position: initial;
  left: 0px;
  top: 0px;
  width: 6px;
  height: 20px;
  background: inherit;
  background-color: rgba(41, 132, 248, 1);
  border: none;
  border-radius: 8px;
  -moz-box-shadow: none;
  -webkit-box-shadow: none;
  box-shadow: none;
  margin-left: 0px;
  margin-top: 0px;
}
.p {
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
  -webkit-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern=1";
  font-kerning: normal;
  margin-left: 5px;
  margin-top: -37px;
}

p {
  margin: 0px;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
  -webkit-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern=1";
  font-kerning: normal;
  display: block;
  margin-block-start: 1em;
  margin-block-end: 1em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
}
.lxbhr {
  background-color: red;
}
.el-row {
  margin-bottom: 20px;
}
.el-col {
  border-radius: 4px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.addBtn {
  background-color: #2984f8;
}
.bbb {
  background-color: white;
  color: #2984f8;
}
</style>